#include<cstdio>
const int maxn=200001;
struct node
{
	int left,right,max;
};

node tree[maxn*4];
int a[maxn];
int h,w,n;
int max(int x,int y)
{
	return x>y?x:y;
}
void buildtree(int L,int R,int u)
{
	tree[u].max=w;
	tree[u].left=L;
	tree[u].right=R;
	if(L==R)return;
	buildtree(L,(L+R)/2,u*2);
	buildtree((L+R)/2+1,R,u*2+1);
}
int query(int val,int u)
{
	if(tree[u].max<val)return -1;
	if(tree[u].left==tree[u].right)
	{
		tree[u].max-=val;
		return tree[u].left;
	}
	if(tree[2*u].max>=val)
	{
		int ans=query(val,2*u);
		tree[u].max=max(tree[u*2].max,tree[u*2+1].max);
		return ans;
	}
	else if(tree[2*u+1].max>=val)
	{
		int ans=query(val,2*u+1);
		tree[u].max=max(tree[u*2].max,tree[u*2+1].max);
		return ans;
	}
}

int main()
{
	freopen("test.in","r",stdin);
	while(scanf("%d%d%d",&h,&w,&n)!=EOF)
	{
		h=n<h?n:h;
		buildtree(1,h,1);
		for(int i=1;i<=n;i++)
		{
			int t;
			scanf("%d",&t);
			printf("%d\n",query(t,1));
		}
	}
	return 0;
}
